<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理系统登录</title>
    <style>
        /* 通用样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            background-color: #f4f7f6;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .login-container {
            background-color: #fff;
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 350px;
            text-align: center;
        }

        .login-container h1 {
            font-size: 24px;
            margin-bottom: 20px;
            color: #333;
        }

        .login-container input[type="password"] {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 16px;
        }

        .login-container button {
            width: 100%;
            padding: 12px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        .login-container button:hover {
            background-color: #45a049;
        }

        .error-message {
            color: red;
            margin-top: 10px;
        }
    </style>
</head>

<body>
    <div class="login-container">
        <h1>登录管理系统</h1>

        <input type="password" id="password-input" placeholder="请输入密码" />
        <button id="login-button">登录</button>

        <div id="error-message" class="error-message"></div>
    </div>

    <script>
        document.getElementById('login-button').addEventListener('click', () => {
            const password = document.getElementById('password-input').value;

            // 将密码发送到后端进行验证
            fetch('/verify-password', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({ password }),
            })
                .then(response => response.json())
                .then(data => {
                    if (data.success) {
                        window.location.href = '/manage';  // 登录成功，跳转到管理界面
                    } else {
                        document.getElementById('error-message').textContent = '密码错误，请重试';
                    }
                })
                .catch(error => {
                    document.getElementById('error-message').textContent = '网络错误，请稍后再试';
                });
        });
    </script>
</body>

</html>
